package com.yyj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyj.common.JwtTokenUtils;
import com.yyj.dao.PetDao;
import com.yyj.entity.Pet;
import com.yyj.entity.Params;
import com.yyj.exception.CustomException;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PetService {
    final
    PetDao petDao;

    public PetService(PetDao petDao){this.petDao = petDao;}
    public List<Pet> getPet(){return petDao.getPet();}
    public void insertPet(Pet pet){
        petDao.insertPet(pet);
    }
    public PageInfo<Pet> getBySearch(Params params){
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        List<Pet> list=petDao.getBySearch(params);
        return PageInfo.of(list);
    }
    public void updatePet(Pet pet){
        petDao.updatePet(pet);
    }
    public void delete(Integer petId){
        petDao.deletePet(petId);
    }
    public Pet findById(Integer petId){
        return petDao.findById(petId);
    }
}
